import API from '../../../api.js';
// 引入SDK核心类
// var QQMapWX = require('../../resource/js/qqmap-wx-jssdk.min.js');
// var qqmapsdk;
// var config = require('../../resource/js/config.js');
// var API = require('../../resource/js/api.js');

var markersData = [];
// var app = getApp();
Page({
  data: {
    autoplay: true,
    interval: 3000,
    duration: 1000,
    showmsg:true
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
   
    var that = this;
     
    // app.util.request({
    //   'url': 'entry/wxapp/getbanner',
    //   success: function (res) {
    //     if (!res.data.message.errno) {
    //       that.setData({
    //         banners: res.data.data,
    //       })
    //     }
    //   }
    // });

    // //系统初始化
    // app.util.request({
    //   'url': 'entry/wxapp/Intro',
    //   success: function (res) {
    //     if (!res.data.message.errno) {

    //       wx.setStorageSync('companyinfo', res.data.data);
    //       wx.setNavigationBarTitle({
    //         title: wx.getStorageSync('companyinfo').name,
    //       })
    //       that.setData({
    //         intro: res.data.data,

    //       })
    //     }
    //   }
    // });



    //获取信息
    // app.util.request({
    //   'url': 'entry/wxapp/GetIndexList',
    //   data: {},
    //   success: function (res) {
    //     if (!res.data.message.errno) {
    //       that.setData({
    //         newhouselist: res.data.data.newhouselist,
    //         oldhouselist: res.data.data.oldhouselist
    //       })
    //     }
    //   },
    //   complete:function(){

    //     wx.hideNavigationBarLoading(); //完成停止加载
    //     wx.stopPullDownRefresh();
    //   }
    // });
    console.log("aaa");
    var param = {
      type: 1
    };
    API.houseList(param,function(res){
      that.setData({
            newhouselist: res,
            // oldhouselist: res.data.data.oldhouselist
          })
    });
    var imageParam={
      houseId:"" ,
      type: 1
    }
    API.imageUrl(imageParam,function(res){
      console.log(res);
      that.setData({
        banners:res
      })
    });
  

    

    



  },
  toNewHouse:function(e)
  {
    wx.switchTab({
      url: "/weixinmao_house/pages/newhouselist/index"
    })

  },
  toOldHouse: function (e) {
    wx.switchTab({
      url: "/weixinmao_house/pages/oldhouselist/index"
    })

  }
  ,
  toAgentlist: function (e) {
    wx.navigateTo({
      url: "/weixinmao_house/pages/agentlist/index"
    })

  }
  ,
  toArticle: function (e) {
    wx.navigateTo({
      url: "/weixinmao_house/pages/salelist/index"
    })

  }
  ,
  toActive:function(e)
  {
    wx.navigateTo({
      url: "/weixinmao_house/pages/active/index"
    })

  }
  ,
  toNewHouseDetail:function(e){

    var id = e.currentTarget.dataset.id;
    console.log(id);
    wx.navigateTo({
      url: "/weixinmao_house/pages/newhousedetail/index?id=" + id
    })

  },
  toOldHouseDetail: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/weixinmao_house/pages/oldhousedetail/index?id=" + id
    })

  },
  toLethouse: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/weixinmao_house/pages/lethouselist/index?id=" + id
    })

  },
  toMessage: function(e)
    {
    wx.navigateTo({
      url: "/weixinmao_house/pages/message/index"
    })

    },
    
  toSearch:function(e){

    wx.navigateTo({
      url: "/weixinmao_house/pages/search/index"
    })


  },
  PubOldhouse:function(e){
    var that = this;
    wx.navigateTo({
      url: "/weixinmao_house/pages/pub/index",
      success:function(){
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg

        })

      }
    })
  },
  PubLethouse: function (e) {
    var that = this;
    wx.navigateTo({
      url: "/weixinmao_house/pages/letpub/index",
      success: function () {
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg

        })

      }
    })
  },

  toSaleOldPub: function (e) {
    var that = this;

    wx.navigateTo({
      url: "/weixinmao_house/pages/saleoldpub/index",
      success: function () {
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg 

        })

      }
    })
  },


  toSalePub:function(e){
    var that = this;

    wx.navigateTo({
      url: "/weixinmao_house/pages/salepub/index",
      success: function () {
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg

        })

      }
    })
  },

  toSaleBuyPub: function (e) {
    var that = this;

    wx.navigateTo({
      url: "/weixinmao_house/pages/salebuypub/index",
      success: function () {
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg

        })

      }
    })
  },

  toSaleLetPub: function (e) {
    var that = this;

    wx.navigateTo({
      url: "/weixinmao_house/pages/saleletpub/index",
      success: function () {
        that.data.showmsg = true;
        that.setData({
          showmsg: that.data.showmsg

        })

      }
    })
  },
 

  goPub:function(e){
    this.data.showmsg = false;
    this.setData({
      showmsg: this.data.showmsg

    })
  
/*
    wx.navigateTo({
      url: "/weixinmao_house/pages/pub/index"
    })

  */

  },
  closemsg:function(e) {
    this.data.showmsg = true;
    this.setData({
      showmsg: this.data.showmsg

    })},
  goMap: function (e) {
    wx.openLocation({
      latitude: parseFloat(wx.getStorageSync('companyinfo').lat),
      longitude: parseFloat(wx.getStorageSync('companyinfo').lng),
      scale: 18,
      name: wx.getStorageSync('companyinfo').name,
      address: wx.getStorageSync('companyinfo').address
    })
  },

  onReady: function () {
    // 页面渲染完成
    const self = this;
  },
  bindInput: function (e) {
    var that = this;
    this.setData({
      inputValue: e.detail.value
    });
    that.onShow();
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading();
    this.onLoad();
    
  },
 
  doCall: function () {
    var tel = this.data.textData.shop_tel;
    wx.makePhoneCall({
      phoneNumber: tel
    })
  },
  onShareAppMessage() {
    return {
      title: wx.getStorageSync('companyinfo').name,
      path: '/weixinmao_house/pages/index/index'
    }
  }

  
})